package study.javaee.practice.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import study.javaee.practice.entity.vo.ProjectJoinApplyVO;

import java.util.List;

public interface ProjectJoinApplyDao extends BaseMapper<ProjectJoinApplyVO> {
    @Select("select b.id,b.name,c.name username,a.user_id,a.content,a.state from project_join_apply a,project b,user c where b.leader_id=#{leaderId} and a.project_id=b.id and a.user_id=c.id")
    List<ProjectJoinApplyVO> getAllProjectJoinApplyVo(Integer leaderId);

    @Select("select b.id,b.name,c.name username,a.user_id,a.content,a.state from project_join_apply a,project b,user c where a.project_id=b.id and a.user_id=c.id")
    List<ProjectJoinApplyVO> getAllProjectJoinApplyVo2();

    @Select("select b.id,b.name,c.name username,a.user_id,a.content,a.state from project_join_apply a,project b,user c where b.leader_id=#{leaderId} and a.project_id=b.id and a.user_id=c.id and b.name like #{name}")
    List<ProjectJoinApplyVO> getProjectJoinApplyVoByName(String name,Integer leaderId);

    @Select("select b.id,b.name,c.name username,a.user_id,a.content,a.state from project_join_apply a,project b,user c where b.leader_id=#{leaderId} and a.project_id=b.id and a.user_id=c.id and c.name like #{username}")
    List<ProjectJoinApplyVO> getProjectJoinApplyVoByUsername(String username,Integer leaderId);

    @Select("select b.id,b.name,c.name username,a.user_id,a.content,a.state from project_join_apply a,project b,user c where b.leader_id=#{leaderId} and a.project_id=b.id and a.user_id=c.id and a.state=#{state}")
    List<ProjectJoinApplyVO> getProjectJoinApplyVoByState(Integer state,Integer leaderId);
}